/*
 *   Copyright (c) 2010-2022, SIUFUNG
 */
package net.siufung.market.base.tenant.controller.assembler;

import com.google.common.collect.Lists;
import java.util.List;
import java.util.Objects;
import net.siufung.core.utils.CopyUtil;
import org.springframework.util.CollectionUtils;
import net.siufung.market.base.tenant.mapper.entity.TenantType;
import net.siufung.market.base.tenant.controller.model.vo.TenantTypeVo;

/**
 *
 * 系统租户类型表 持久层展示层组装器
 *
 * @author 陈建峰
 * @since 2022-07-06 14:45:08
 */
public class TenantTypeAssembler {

    /**
     * TenantType 转换成 TenantTypeVo
     * @param tenantType 数据库实体
     * @return TenantTypeVo 视图
     */
    public static TenantTypeVo from(TenantType tenantType){
        if(!Objects.isNull(tenantType)){
            TenantTypeVo tenantTypeVo = new TenantTypeVo();
            CopyUtil.copyProperties(tenantType, tenantTypeVo);
            return tenantTypeVo;
        }
        return null;
    }

    /**
     * TenantTypeList 转换成 TenantTypeVoList
     * @param tenantTypeList 数据库实体集合
     * @return List<TenantTypeVo> 视图集合
     */
    public static List<TenantTypeVo> fromList(List<TenantType> tenantTypeList){
        List<TenantTypeVo> tenantTypeVoList = Lists.newArrayList();
        if(!CollectionUtils.isEmpty(tenantTypeList)){
            TenantTypeVo tenantTypeVo;
            for (TenantType tenantType: tenantTypeList) {
                tenantTypeVo = new TenantTypeVo();
                CopyUtil.copyProperties(tenantType, tenantTypeVo);
                tenantTypeVoList.add(tenantTypeVo);
            }
        }
        return tenantTypeVoList;
    }
}

